package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     *
     * @param categoryId
     *
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    public void countByCategoryId(Dish categoryId);

    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    public void insertDish(Dish dish);

    /**
     * 分页查询菜品
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery (DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id} ")
    Dish getById(Long id);

    /**
     * 根据id删除菜品
     * @param id
     */
    @Delete("delete from dish where id in (#{id})")
    void deleteById(Long id);

    /**
     * 修改菜品
     * @param dishDTO
     */
    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dishDTO);

    /**
     * 根据dish查询菜品
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);
}
